import request from '@/utils/request'

// 查询产品列表
export function listProduct(query) {
  return request({
    url: '/comProducts/page',
    method: 'get',
    params: query
  })
}

// 查询产品列表
export function listProductAll(query) {
  return request({
    url: '/comProducts/list',
    method: 'get',
    params: query
  })
}

// 查询产品详细
export function getProduct(ProductId) {
  return request({
    url: '/comProducts/get/' + ProductId,
    method: 'get'
  })
}

// 新增产品
export function addProduct(data) {
  return request({
    url: '/comProducts/add',
    method: 'post',
    data,
  })
}

// 修改产品
export function updateProduct(data) {
  return request({
    url: '/comProducts/update/' + data.ProductId,
    method: 'patch',
    data: data
  })
}

// 产品数据权限
export function dataScope(data) {
  return request({
    url: '/comProducts/dataScope',
    method: 'patch',
    data: data
  })
}

// 产品状态修改
export function changeProductStatus(ProductId, useFlag) {
  const data = {
    ProductId,
    useFlag
  }
  return request({
    url: '/comProducts/changeStatus',
    method: 'patch',
    data: data
  })
}

// 删除产品
export function delProduct(ProductId) {
  return request({
    url: '/comProducts/batch/' + ProductId,
    method: 'delete'
  })
}

// 查询产品已授权用户列表
export function allocatedUserList(query) {
  return request({
    url: '/comProducts/authUser/allocatedList',
    method: 'get',
    params: query
  })
}

// 查询产品未授权用户列表
export function unallocatedUserList(query) {
  return request({
    url: '/comProducts/authUser/unallocatedList',
    method: 'get',
    params: query
  })
}

// 取消用户授权产品
export function authUserCancel(data) {
  return request({
    url: '/comProducts/authUser/cancel',
    method: 'patch',
    data: data
  })
}

// 批量取消用户授权产品
export function authUserCancelAll(data) {
  return request({
    url: '/comProducts/authUser/cancelAll',
    method: 'patch',
    data: data
  })
}

// 授权用户选择
export function authUserSelectAll(data) {
  return request({
    url: '/comProducts/authUser/selectAll',
    method: 'patch',
    data: data
  })
}

// 根据产品ID查询部门树结构
export function deptTreeSelect(ProductId) {
  return request({
    url: '/comProducts/deptTree/' + ProductId,
    method: 'get'
  })
}
